package com.zhzh.sc.demo.proxy.cglib;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

public class SimpleMethodInterceptor implements MethodInterceptor {

    private static SimpleMethodInterceptor instance = new SimpleMethodInterceptor();

    public static SimpleMethodInterceptor getInstance() {
        return instance;
    }

    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        System.out.println("before");
        Object result = methodProxy.invokeSuper(o, objects);
        System.out.println("after");
        return result;
    }
}
